<template>
  <div>
    <LikeDog
      v-for="(item, index) in list"
      :key="index"
      :url="item.url"
      :uname="item.name"
      @addFn="addFn"
    ></LikeDog>
    <DogAdd :newArr="newArr"></DogAdd>
  </div>
</template>

<script>
import LikeDog from './components/LikeDog.vue'
import DogAdd from './components/DogAdd.vue'
export default {
  components: {
    LikeDog,
    DogAdd,
  },
  data() {
    return {
      newArr: [],
      list: [
        {
          url: 'https://img2.baidu.com/it/u=3421477252,3719550838&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',
          name: '高达',
        },
        {
          url: 'https://img2.baidu.com/it/u=73055802,2758143707&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500',
          name: '小狗狗',
        },
        {
          url: 'https://img14.360buyimg.com/pop/jfs/t1/190157/19/5071/152944/60ae710bE0abc11bd/46a6b1367a0e2356.jpg',
          name: '俩只小狗狗',
        },
        {
          url: 'https://img0.baidu.com/it/u=3289461667,2295508139&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500',
          name: '一只柯基',
        },
      ],
    }
  },
  methods: {
    addFn(name) {
      let obj = this.list.find((item) => item.name == name)
      this.newArr.push(obj)
    },
  },
}
</script>

<style></style>
